package com.lxt.cloud.streammq.service.impl;

import com.lxt.cloud.streammq.service.IMessageProvider;
import org.springframework.cloud.stream.annotation.EnableBinding;
import org.springframework.cloud.stream.messaging.Source;
import org.springframework.messaging.MessageChannel;
import org.springframework.messaging.support.MessageBuilder;

import javax.annotation.Resource;
import java.time.LocalTime;

@EnableBinding(Source.class)
public class MessageProviderImpl implements IMessageProvider {

    @Resource
//    必须叫output
    private MessageChannel output;
    @Override
    public void send() {
        LocalTime t = LocalTime.now();
        output.send(MessageBuilder.withPayload(t.toString()).build());
        System.out.println("*******time:"+t.toString());
    }
}
